#include <iostream>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef int DataType;

class Stack
{
public:
	void Init()
	{
		a = (DataType*)malloc(sizeof(DataType)*4);
		if (a == NULL)
		{
			perror("malloc falied");
			return;
		}
		capacity = 4;
		top = 0;
	}

	void Push(DataType x)
	{
		if (top == capacity)
		{
			DataType* tmp = (DataType*)realloc(a, sizeof(DataType) * capacity * 2);
			if (a == NULL)
			{
				perror("realloc failed");
				return;
			}
			capacity *= 2;
		}
		a[top] = x;
		top++;
	}

	void Pop()
	{
		assert(top);
		top--;
	}

	void Destroy()
	{
		free(a);
		a = NULL;
		top = 0;
		capacity = 0;
	}

private:
	DataType* a;
	int top;
	int capacity;
};


int main()
{
	return 0;
}